//
//  SleeveTableViewCell.m
//  WhereToTravel
//
//  Created by dlios on 15/10/14.
//  Copyright © 2015年 zhoushengmin. All rights reserved.
//

#import "SleeveTableViewCell.h"

#define W self.contentView.frame.size.width/375
#define H self.contentView.frame.size.height/300

@implementation SleeveTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [[NSNotificationCenter defaultCenter] postNotificationName:@"night" object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(night) name:@"night" object:nil];
        [self createView];
    }
    return self;
}

- (void)createView {
    [super createView];
    self.upBigImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.upBigImageView];
    self.upBigImageView.layer.masksToBounds = YES;
    
    self.upMissImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.upMissImageView];
    self.upMissImageView.layer.masksToBounds = YES;
    
    self.mistLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:18];
    self.mistLabel.numberOfLines = 0;
    
    self.downLeftLabel.font = [UIFont systemFontOfSize:12];
    
    self.downMistLabel.font = [UIFont systemFontOfSize:12];
    
    self.downRightLabel.font = [UIFont systemFontOfSize:12];
    
    self.downLabel.font = [UIFont systemFontOfSize:16];
    self.downLabel.textAlignment = NSTextAlignmentRight;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.upBigImageView.frame = CGRectMake(5 * W, 5 * H, 365 * W, 200 * H);
    self.upBigImageView.layer.cornerRadius = 30 * H;
    self.upMissImageView.frame = CGRectMake(270 * W, 160 * H, 50 * W, 50 * H);
    self.upMissImageView.layer.cornerRadius = 25 * H;
    self.mistLabel.frame = CGRectMake(5 * W, 210 * H, 365 * W, 50 * H);
    self.downLeftLabel.frame = CGRectMake(5 * W, 265 * H, 100 * W, 30 * H);
    self.downMistLabel.frame = CGRectMake(110 * W, 265 * H, 120 * W, 30 * H);
    self.downRightLabel.frame = CGRectMake(240 * W, 265 * H, 60 * W, 30 * H);
    self.downLabel.frame = CGRectMake(305 * W, 260 * H, 65 * W, 40 * H);
}

- (void)night {
    if ([SingletonNight shareSingletonNight].isSelete == YES) {
        self.mistLabel.textColor = [UIColor whiteColor];
        self.downMistLabel.textColor = [UIColor whiteColor];
        self.downLeftLabel.textColor = [UIColor whiteColor];
        self.downRightLabel.textColor = [UIColor whiteColor];
        self.downLabel.textColor = [UIColor whiteColor];
    }
    else {
        self.mistLabel.textColor = [UIColor blackColor];
        self.downMistLabel.textColor = [UIColor blackColor];
        self.downLeftLabel.textColor = [UIColor blackColor];
        self.downRightLabel.textColor = [UIColor blackColor];
        self.downLabel.textColor = [UIColor blackColor];
    }
}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"night" object:nil];
}


@end
